﻿CREATE PROCEDURE [dbo].[sp_Insert_OptimizedLeads]
	(
		@MdNumber VARCHAR(10),
		@LeadBlockCode VARCHAR(50),
		@LeadsString TEXT,
		@Count INT,
		@ACount INT,
		@LCount INT,
		@BCount INT,
		@NCount INT
	)
AS
	SET NOCOUNT ON
	DELETE FROM [dbo].[OptimizedLeads] WHERE MdNumber = @MdNumber and LeadBlockCode = @LeadBlockCode
	
	INSERT INTO [dbo].[OptimizedLeads]
			   ([MdNumber]
			   ,[LeadBlockCode]
			   ,[LeadsString]
			   ,[AddTS]
			   ,[LeadCount]
			   ,[ActiveCount]
			   ,[LapsedCount]
			   ,[BusinessCount]
			   ,[NeighborCount])
		 VALUES
			   (@MdNumber
			   ,@LeadBlockCode
			   ,@LeadsString
			   ,GETDATE()
			   ,@Count
			   ,@ACount
			   ,@LCount
			   ,@BCount
			   ,@NCount)
